package com.wlz.principle.openclose;


import com.wlz.principle.openclose.impl.NovelBook;
import com.wlz.principle.openclose.impl.OffNovelBook;

import java.util.ArrayList;

public class BookStore {
    private final static ArrayList<IBook> bookList = new ArrayList<IBook>();

    //static静态模块初始化数据， 实际项目中一般是由持久层完成
    static {
        bookList.add(new NovelBook("西游记", 32));
        bookList.add(new NovelBook("三国演义", 56));
        bookList.add(new NovelBook("红楼梦", 35));
        bookList.add(new OffNovelBook("水浒传", 43));
    }

    //模拟书店买书
    public static void main(String[] args) {
        System.out.println("-----------书店卖出去的书籍记录如下： -----------");
        for (IBook book : bookList) {
            System.out.println("书籍名称： " + book.getName()
                    + "\t书籍价格： "+ book.getPrice()+"元");
        }
    }
}
